extends Control

@export_group("UI")
@export var letter_title: Label
@export var letter_time: Label
@export var letter_text: Label
@export var letter_name: Label

@export_group("信件内容")
@export var letter_content: LetterContent

func _ready() -> void:
	hide()
	
	visibility_changed.connect(func ():
		get_tree().paused = visible
	)

func display():
	letter_title.text = letter_content.letter_title
	letter_time.text = letter_content.letter_time
	letter_text.text = letter_content.letter_content
	letter_name.text = letter_content.letter_name

func show_letter(res: LetterContent):
	letter_content = res
	show()
	display()

func _on_gui_input(event: InputEvent) -> void:
	if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed():
		hide()
		if GameManager.is_end:
			GameManager.game_end()
